package test.demo;

import com.alibaba.fastjson.JSON;
import tech.waterism.modelbase.PredictBase;
import tech.waterism.modelbase.PredictResult;

import java.util.*;

/**
 * 大伙房模型（大伙房产汇流）
 *
 * @author 初京刚
 * @version 1.0
 * @date 2022-1-7
 */
public class DHF_ys extends PredictBase {

    /**
     * 圆周率
     */
    final static double PAI = (Math.PI);
    /**
     * 上层蓄水容量
     */
    private double s0;
    /**
     * 下层蓄水容量
     */
    private double u0;
    /**
     * 地下水蓄水容量，即下层蓄水容量与地下水库蓄水容量之和
     */
    private double d0;
    /**
     * 流域蒸散发折算系数
     */
    private double Kc;

    //    /**
    //     * 初始表层蓄水容量(6月1号8时)
    //     */
    //    private double s00;
    //
    //    /**
    //     * 初始下层蓄水容量(6月1号8时)
    //     */
    //    private double u00;
    //
    //    /**
    //     * 表层蓄水容量增量
    //     */
    //    private double sd;
    //
    //    /**
    //     * 下层蓄水容量增量
    //     */
    //    private double ud;
    /**
     * yL与RL的比值
     */
    private double Kw;

    //    /**
    //     * 前期净雨折减系数,ka = 0.15
    //     */
    //    private double ka;
    /**
     * 点的下层下渗曲线的曲率系数
     */
    private double k2;
    /**
     * 不透水面积比例
     */
    private double g;
    /**
     * 表层蓄水容量空间分布曲线形状参数
     */
    private double a;
    /**
     * 流域内下渗率抛物线形状系数（总下渗或下层下渗）
     */
    private double B;
    /**
     * 初始流域表层平均蓄水量
     */
    private double sa0;
    /**
     * 初始流域下层平均蓄水量
     */
    private double ua0;
    /**
     * 初始前期影响雨量
     */
    private double ya0;
    /**
     * 表层蓄水量
     */
    private double[] sa;
    /**
     * 下层蓄水量
     */
    private double[] ua;
    /**
     * 前期影响雨量
     */
    private double[] ya;
    /**
     * 地下水库下渗强度
     */
    private double[] rL;
    /**
     * 流域 月蒸发量（mm）
     */
    private double[] ES;

    //    /**
    //     * 降雨等级数组（大雨、中雨、小雨）
    //     */
    //    private double[] rainLevel;
    //
    //    /**
    //     * 大雨、中雨、小雨时4、5、6、7、8、9、10月流域日潜在蒸发量（mm）
    //     */
    //    private double[][] Eall;
    /**
     * 流域 时段蒸发量（mm）
     */
    private double[] floodE;
    /**
     * 地表汇流曲线形状参数
     */
    private double AA;
    /**
     * 地表汇流曲线形状参数
     */
    private double DD;
    /**
     * 地表汇流曲线形状参数
     */
    private double CC;
    /**
     * 地表汇流曲线比例系数
     */
    private double K3;
    /**
     * 地表汇流曲线参数，描述峰现时间
     */
    private double COE;
    /**
     * 特征河长比例系数，为待定参数
     */
    private double B0;
    /**
     * 汇流曲线底宽求解指数，为待定参数
     */
    private double K0;
    /**
     * 前期净雨影响衰减系数
     */
    private double Ka;
    /**
     * 地下径流与地面壤中流汇流曲线底宽的比例系数
     */
    private double N;
    /**
     * 流域最大河长
     */
    private double L;
    /**
     * 地下汇流曲线形状参数
     */
    private double AAL;
    /**
     * 地下汇流曲线形状参数
     */
    private double DDL;
    /**
     * 地下汇流曲线形状参数
     */
    private double CCL;
    /**
     * 地下汇流曲线比例系数
     */
    private double K3L;
    /**
     * 地表汇流曲线底宽
     */
    private double Tm;
    /**
     * 特征河长
     */
    private double LB;
    /**
     * 模拟总产流
     */
    private double[] RunoffSim;

    /**
     * 模拟总径流
     */
    private double[] QSim;

    /**
     * 不透水面积产流
     */
    private double[] y0;

    /**
     * 净雨
     */
    private double[] PE;

    /**
     * 分水源-地面壤中流
     */
    private double[] yu;

    /**
     * 分水源-地下径流
     */
    private double[] yL;

    /**
     * 地表壤中流与地下径流之和
     */
    private double[] y;

    /**
     * 汇流-地面壤中流
     */
    private double[] qs;

    /**
     * 汇流-地下径流
     */
    private double[] ql;

    //    /**
    //     * 前期降水时间
    //     */
    //    private Date[] preFloodTm;
    //
    //    /**
    //     * 前期降水量
    //     */
    //    private double[] preFloodDrp;
    //
    //    /**
    //     * 前期降水序列长度
    //     */
    //    private Integer preFloodRainRange;
    //
    //    /**
    //     * 前期降水时段长
    //     */
    //    private double preTimeInterval;

    /**
     * 降水时间
     */
    private Date[] floodTm;

    /**
     * 降水量
     */
    private double[] floodDrp;

    /**
     * 降水序列长度
     */
    private Integer floodRainRange;

    /**
     * 降水时段长
     */
    private double timeInterval;

    /**
     * 流域面积
     */
    private double Area;

    /**
     * 流域表层、下层平均蓄量初值、前期影响雨量初值
     */
    private double[] WInitialDay;

    public DHF_ys(Map<String, String> data) {
        super();
        sa0 = Double.parseDouble(data.get("SA0"));
        ua0 = Double.parseDouble(data.get("UA0"));
        ya0 = Double.parseDouble(data.get("YA0"));
        WInitialDay = new double[]{sa0, ua0, ya0};

        s0 = Double.parseDouble(data.get("S0"));
        u0 = Double.parseDouble(data.get("U0"));
        d0 = Double.parseDouble(data.get("D0"));
        k2 = Double.parseDouble(data.get("K2"));
        Ka = Double.parseDouble(data.get("KA"));
        Kc = Double.parseDouble(data.get("K"));
        Kw = Double.parseDouble(data.get("KW"));
        g = Double.parseDouble(data.get("G"));
        a = Double.parseDouble(data.get("A"));
        B = Double.parseDouble(data.get("B"));
        B0 = Double.parseDouble(data.get("B0"));
        K0 = Double.parseDouble(data.get("K0"));
        N = Double.parseDouble(data.get("N"));
        L = Double.parseDouble(data.get("L"));
        DD = Double.parseDouble(data.get("DD"));
        CC = Double.parseDouble(data.get("CC"));
        COE = Double.parseDouble(data.get("COE"));
        DDL = Double.parseDouble(data.get("DDL"));
        CCL = Double.parseDouble(data.get("CCL"));
        Area = Double.parseDouble(data.get("F"));

        ES = JSON.parseObject(data.get("ES"), double[].class);
        floodTm = JSON.parseObject(data.get("dt"), Date[].class);// input[i].data.dt
        floodDrp = JSON.parseObject(data.get("rain"), double[].class);// input[i].data.rain
        floodE = JSON.parseObject(data.get("evaporation"), double[].class);  // input[i].data.evaporation
        floodRainRange = floodDrp.length;
        timeInterval = Double.parseDouble(data.get("clen"));                  // index.clen
        RunoffSim = new double[floodRainRange];
        QSim = new double[floodRainRange];
        y0 = new double[floodRainRange];
        PE = new double[floodRainRange];
        yu = new double[floodRainRange];
        yL = new double[floodRainRange];
        y = new double[floodRainRange];
        rL = new double[floodRainRange];
        qs = new double[floodRainRange];
        ql = new double[floodRainRange];
    }

    @Override
    public void init() {

    }

    @Override
    public PredictResult predict() {
        PredictResult result = new PredictResult();
        Map<String, double[]> map = DHF_Model();

        double[][] RSim = new double[4][];
        //不透水面积产流
        RSim[0] = map.get("y0");
        //流域地表壤中流
        RSim[1] = map.get("yu");
        //流域地下径流
        RSim[2] = map.get("yL");
        //流域地表壤中流与地下径流之和
        RSim[3] = map.get("y");

        //流域面积总产流，不透水面积产流y0[j]+ 流域表层径流yu[j] +  流域地下径流yL[j];
        result.setRunoffSim(map.get("runoffSim"));
        result.setRSim(RSim);
        //汇流计算结果
        result.setQSim(map.get("QSim"));

        // 更新状态
        List<String> sap = toStringList(sa);
        List<String> uap = toStringList(ua);
        List<String> yap = toStringList(ya);
        //        List<String> rLp = toStringList(rL);
        //        List<String> qsp = toStringList(qs);
        //        List<String> qlp = toStringList(ql);

        Map<String, List<String>> status = new HashMap<>();
        //表层蓄力量
        status.put("SA0", sap);
        //下层蓄水量
        status.put("UA0", uap);
        //前期影响雨量
        status.put("YA0", yap);
        //        //地下水库下渗强度
        //        status.put("rLp", rLp);
        //        //汇流-地面壤中流
        //        status.put("qsp", qsp);
        //        //汇流-地下径流
        //        status.put("qlp", qlp);
        result.setNewStatus(status);

        return result;
    }
    public PredictResult predict_pa() {
        PredictResult result = new PredictResult();
        Map<String, double[]> map = DHF_Model();

        double[][] RSim = new double[4][];
        //不透水面积产流
        RSim[0] = map.get("y0");
        //流域地表壤中流
        RSim[1] = map.get("yu");
        //流域地下径流
        RSim[2] = map.get("yL");
        //流域地表壤中流与地下径流之和
        RSim[3] = map.get("y");

        //流域面积总产流，不透水面积产流y0[j]+ 流域表层径流yu[j] +  流域地下径流yL[j];
        result.setRunoffSim(map.get("runoffSim"));
        result.setRSim(RSim);
        //汇流计算结果
        result.setQSim(map.get("QSim"));

        // 更新状态
        List<String> sap = toStringList(sa);
        List<String> uap = toStringList(ua);
        List<String> yap = toStringList(ya);
        //        List<String> rLp = toStringList(rL);
        //        List<String> qsp = toStringList(qs);
        //        List<String> qlp = toStringList(ql);

        Map<String, List<String>> status = new HashMap<>();
        //表层蓄力量
        status.put("SA0", sap);
        //下层蓄水量
        status.put("UA0", uap);
        //前期影响雨量
        status.put("YA0", yap);
        //        //地下水库下渗强度
        //        status.put("rLp", rLp);
        //        //汇流-地面壤中流
        //        status.put("qsp", qsp);
        //        //汇流-地下径流
        //        status.put("qlp", qlp);
        result.setNewStatus(status);

        return result;
    }


    /**
     * 大伙房产流
     *
     * @return 净雨过程
     */
    private void dhf_runoff() {
        sa = new double[floodRainRange + 1];
        ua = new double[floodRainRange + 1];
        ya = new double[floodRainRange + 1];

        sa[0] = WInitialDay[0];
        ua[0] = WInitialDay[1];
        ya[0] = WInitialDay[2];

        double Pc;// 净渗雨强，净雨-不透水产流
        double EDt; // EDt为蒸散发，等于Kc * E（实测蒸发，即ES[]或时段）
        double Sm; // 与sa值相对应的纵坐标值（流域单点表层最大蓄水量）
        double rr; // 下渗强度
        double un; // 与ua值相对应的纵坐标值（流域单点下层最大下渗量）
        double dn; // 与da（地下水库蓄水量与下层蓄水里之和）值相对应的纵坐标值（流域单点下层与地下水库的最大下渗量）
        double Ec; // 土壤表层时段最大蒸散发
        double Eb; // 土壤表层累积最大蒸散发
        double EL; // 下层蒸散发
        double Eu; // 表层可蒸发量
        double Z1, Z2;

        if (sa[0] > s0)
            sa[0] = s0;
        if (ua[0] > u0)
            ua[0] = u0;
        //        sa[0] = sa0; // 初始表层蓄水量
        //        ua[0] = ua0; // 初始下层蓄水量
        //        ya[0] = ya0; // 初始全部径流
        //        double s0 = s00;
        //        double u0 = u00;
        for (int i = 0; i < floodRainRange; i++) {
            //            s0 = s0 + timeStep/day * sd; // 表示现在时刻的上层蓄水容量（计算值）， sd 表层蓄水容量增量
            //            u0 = u0 + timeStep/day * ud;
            if (sa[i] > s0) {
                sa[i] = s0;
            }
            if (ua[i] > u0) {
                ua[i] = u0;
            }
            yu[i] = 0.0;  //地面壤中流
            yL[i] = 0.0; //地下径流
            Eb = 0.0; //初始化Eb

            //以下计算蒸发量
            //            EDt = f_emt(tm[i], rain[i]); //E--雨间蒸散发量
            if (floodE == null || floodE.length != floodRainRange) {
                EDt = Kc * calcEvaporationPotential(floodTm[i], timeInterval);
            } else {
                EDt = Kc * floodE[i];
            }

            PE[i] = floodDrp[i] - EDt; //PE--净雨强,floodDrp[i]-第i时段的降雨量
            y0[i] = g * PE[i]; //y0--不透水面积上的直接径流
            Pc = PE[i] - y0[i]; //Pc--净渗雨强

            //地面壤中流和地下径流之和y的计算
            //-----------当降雨量超过流域蒸发能力时，即净渗雨强Pc>0------------//
            if (Pc > 0.0) {
                double temp = (Math.pow(1 - sa[i] / s0, 1 / a));
                Sm = a * s0 * (1 - temp); // 2-103,Sm--相应于Sa的点蓄水量（流域单点表层最大蓄水量）
                if (Sm + Pc < a * s0) {
                    temp = (Math.pow(1 - (Sm + Pc) / (a * s0), a));
                    rr = Pc + sa[i] - s0 + s0 * temp; //2-104,R--下渗强度
                } else {
                    rr = Pc - (s0 - sa[i]); //2-96
                }
                /*********************表层***********************/
                temp = (Math.pow(1 - ua[i] / u0, 1 / B));
                un = B * u0 * (1 - temp); //2-128
                temp = (Math.pow(1 - ua[i] / u0, u0 / (B * d0)));
                dn = B * d0 * (1 - temp); //2-133

                Z1 = (1 - Math.exp(-k2 * timeInterval * u0 / d0)); //2-119
                Z2 = (1 - Math.exp(-k2 * timeInterval)); //2-120
                //地面壤中流和地下径流之和
                if (rr + Z2 * un < Z2 * B * u0) {
                    temp = (Math.pow((1 - (Z2 * un + rr) / (Z2 * B * u0)), B));
                    y[i] = rr + Z2 * (ua[i] - u0) + Z2 * u0 * temp; //2-129
                } else {
                    y[i] = rr + Z2 * (ua[i] - u0); //2-130
                }
                //求地面壤中流yu
                temp = (Math.pow(1 - ua[i] / u0, u0 / d0));
                if (Z1 * dn + rr < Z1 * B * d0) {
                    double temp1 = 1 - (Z1 * dn + rr) / (Z1 * B * d0);
                    double temp2 = (Math.pow(temp1, B));
                    yu[i] = rr - Z1 * d0 * temp + Z1 * d0 * temp2; //2-131
                } else {
                    yu[i] = rr - Z1 * d0 * temp; //2-132
                }
                //求地下径流yL
                yL[i] = (y[i] - yu[i]) * Kw; //2-134

                /*需保留最后一个时段末的状态值，去掉时段初值限制条件*/
                //               if(i + 1 < floodRainRange) {
                //表面蓄水量计算sa[i+1]
                if (Sm + Pc < a * s0) {
                    double temp1 = 1 - (Sm + Pc) / (a * s0);
                    double temp2 = (Math.pow(temp1, a));
                    sa[i + 1] = s0 * (1 - temp2); //2-138
                } else {
                    sa[i + 1] = sa[i] + Pc - rr; //2-140
                }
                if (sa[i + 1] > s0) {
                    sa[i + 1] = s0; //表层蓄水量不能超过超过表层蓄水容量，即饱和状态
                }
                //下层土壤蓄水量ua[i+1]
                ua[i + 1] = ua[i] + rr - y[i]; //2-141
                if (ua[i + 1] > u0) {
                    ua[i + 1] = u0;
                }
                //                }
                Eb = 0.0;
            } else {//---------当日流域平均降雨量小于流域平均蒸散发能力，即P<Ed时--------//
                rr = 0.0; //下渗强度
                Ec = EDt - floodDrp[i]; //2-144
                Eb = Eb + Ec; //2-145
                //                if (Eb > sa[0]) {
                //                    Eb = sa[0]; //限制蒸发深度
                //                }

                //表层可蒸发量Eu,两个假定
                double temp1 = (Math.pow(1 - (Eb - Ec) / (a * s0), a));
                double temp2 = (Math.pow(1 - Eb / (a * s0), a));
                //Eu = s0 * (temp1 - temp2); //2-146
                ////////防止出现负数///////////////
                if (Eb / (a * s0) <= 0.999999 & (Eb - Ec) / (a * s0) <= 0.999999) {
                    Eu = s0 * (temp1 - temp2); // 2-146
                } else if (Eb / (a * s0) >= 1.00001 & (Eb - Ec) / (a * s0) <= 0.999999) {
                    Eu = s0 * Math.pow(temp1, a);
                } else {
                    Eu = 0.00001;
                }

                if (sa[i] - Eu < 0.0) {
                    EL = (Ec - sa[i]) * ua[i] / u0; //2-149
                    if (i + 1 < floodRainRange) {
                        sa[i + 1] = 0.0;
                        ua[i + 1] = ua[i] - EL; //2-150
                        if (ua[i + 1] < 0.0) {
                            ua[i + 1] = 0.0;
                        }
                    }
                } else {
                    EL = (Ec - Eu) * ua[i] / u0; //2-148
                    if (i + 1 < floodRainRange) {
                        sa[i + 1] = sa[i] - Eu; //2-147
                        ua[i + 1] = ua[i] - EL; //2-150
                        if (ua[i + 1] < 0.0) {
                            ua[i + 1] = 0.0;
                        }
                    }
                }

                y[i] = 0.0; //表层径流和地下径流之和
                y0[i] = 0.0; //直接径流
                yu[i] = 0.0; //地面壤中流
                yL[i] = 0.0; //地下径流
            }

            /*需保留最后一个时段末的状态值，去掉时段初值限制条件*/
            //            if(i + 1 < floodRainRange) {
            if (sa[i + 1] > s0) {
                sa[i + 1] = s0; // 表层蓄水量不能超过表层蓄水容量，即饱和状态
            }
            if (sa[i + 1] < 0) {
                sa[i + 1] = 0;
            }
            if (ua[i + 1] < 0) {
                ua[i + 1] = 0f;
            }
            if (ua[i + 1] > u0) {
                ua[i + 1] = u0;
                // System.out.println("**ua["+(i+1)+"]"+ua[i+1]);
            }
            //            }
        }
    }

    //   private double f_emt( Date dt_rain, double pt) {
    //        //得到该时刻的时段蒸发能力，time_step—表示时段间隔,emt—表示各月蒸发能力，
    //        //pt—表示时段降雨，dt_rain—表示降雨时间
    //        int iNumLevel = rainLevel.length; //表示是晴天、雨天或阴天的情况数
    //        int level = 0;
    //        double p_day = pt * 24 / timeInterval; //将时段降雨转换成日降雨
    //        for (int i = 0; i < iNumLevel; i++) {
    //            if (p_day <= rainLevel[i]) {
    //                level = i;
    //                break;
    //            }
    //        }
    //        Calendar time = Calendar.getInstance();
    //        time.setTime(dt_rain); //降雨现在时间
    //        int i_month = time.get(Calendar.MONTH) + 1; //得到月数
    //        double ev = Eall[level][i_month];;
    //        ev = ev * timeInterval / 24; //时段蒸发能力
    //        return ev;
    //    }
    private void dhf_runoff_pa() {
        sa = new double[floodRainRange + 1];
        ua = new double[floodRainRange + 1];
        ya = new double[floodRainRange + 1];

        sa[0] = WInitialDay[0];
        ua[0] = WInitialDay[1];
        ya[0] = WInitialDay[2];

        double Pc;// 净渗雨强，净雨-不透水产流
        double EDt; // EDt为蒸散发，等于Kc * E（实测蒸发，即ES[]或时段）
        double Sm; // 与sa值相对应的纵坐标值（流域单点表层最大蓄水量）
        double rr; // 下渗强度
        double un; // 与ua值相对应的纵坐标值（流域单点下层最大下渗量）
        double dn; // 与da（地下水库蓄水量与下层蓄水里之和）值相对应的纵坐标值（流域单点下层与地下水库的最大下渗量）
        double Ec; // 土壤表层时段最大蒸散发
        double Eb; // 土壤表层累积最大蒸散发
        double EL; // 下层蒸散发
        double Eu; // 表层可蒸发量
        double Z1, Z2;

        if (sa[0] > s0)
            sa[0] = s0;
        if (ua[0] > u0)
            ua[0] = u0;
        //        sa[0] = sa0; // 初始表层蓄水量
        //        ua[0] = ua0; // 初始下层蓄水量
        //        ya[0] = ya0; // 初始全部径流
        //        double s0 = s00;
        //        double u0 = u00;
        for (int i = 0; i < floodRainRange; i++) {
            //            s0 = s0 + timeStep/day * sd; // 表示现在时刻的上层蓄水容量（计算值）， sd 表层蓄水容量增量
            //            u0 = u0 + timeStep/day * ud;
            if (sa[i] > s0) {
                sa[i] = s0;
            }
            if (ua[i] > u0) {
                ua[i] = u0;
            }
            yu[i] = 0.0;  //地面壤中流
            yL[i] = 0.0; //地下径流
            Eb = 0.0; //初始化Eb

            //以下计算蒸发量
            //            EDt = f_emt(tm[i], rain[i]); //E--雨间蒸散发量
            if (floodE == null || floodE.length != floodRainRange) {
                EDt = Kc * calcEvaporationPotential(floodTm[i], timeInterval);
            } else {
                EDt = Kc * floodE[i];
            }

            PE[i] = floodDrp[i] - EDt; //PE--净雨强,floodDrp[i]-第i时段的降雨量
            y0[i] = g * PE[i]; //y0--不透水面积上的直接径流
            Pc = PE[i] - y0[i]; //Pc--净渗雨强

            //地面壤中流和地下径流之和y的计算
            //-----------当降雨量超过流域蒸发能力时，即净渗雨强Pc>0------------//
            if (Pc > 0.0) {
                double temp = (Math.pow(1 - sa[i] / s0, 1 / a));
                Sm = a * s0 * (1 - temp); // 2-103,Sm--相应于Sa的点蓄水量（流域单点表层最大蓄水量）
                if (Sm + Pc < a * s0) {
                    temp = (Math.pow(1 - (Sm + Pc) / (a * s0), a));
                    rr = Pc + sa[i] - s0 + s0 * temp; //2-104,R--下渗强度
                } else {
                    rr = Pc - (s0 - sa[i]); //2-96
                }
                /*********************表层***********************/
                temp = (Math.pow(1 - ua[i] / u0, 1 / B));
                un = B * u0 * (1 - temp); //2-128
                temp = (Math.pow(1 - ua[i] / u0, u0 / (B * d0)));
                dn = B * d0 * (1 - temp); //2-133

                Z1 = (1 - Math.exp(-k2 * timeInterval * u0 / d0)); //2-119
                Z2 = (1 - Math.exp(-k2 * timeInterval)); //2-120
                //地面壤中流和地下径流之和
                if (rr + Z2 * un < Z2 * B * u0) {
                    temp = (Math.pow((1 - (Z2 * un + rr) / (Z2 * B * u0)), B));
                    y[i] = rr + Z2 * (ua[i] - u0) + Z2 * u0 * temp; //2-129
                } else {
                    y[i] = rr + Z2 * (ua[i] - u0); //2-130
                }
                //求地面壤中流yu
                temp = (Math.pow(1 - ua[i] / u0, u0 / d0));
                if (Z1 * dn + rr < Z1 * B * d0) {
                    double temp1 = 1 - (Z1 * dn + rr) / (Z1 * B * d0);
                    double temp2 = (Math.pow(temp1, B));
                    yu[i] = rr - Z1 * d0 * temp + Z1 * d0 * temp2; //2-131
                } else {
                    yu[i] = rr - Z1 * d0 * temp; //2-132
                }
                //求地下径流yL
                yL[i] = (y[i] - yu[i]) * Kw; //2-134

                /*需保留最后一个时段末的状态值，去掉时段初值限制条件*/
                //               if(i + 1 < floodRainRange) {
                //表面蓄水量计算sa[i+1]
                if (Sm + Pc < a * s0) {
                    double temp1 = 1 - (Sm + Pc) / (a * s0);
                    double temp2 = (Math.pow(temp1, a));
                    sa[i + 1] = s0 * (1 - temp2); //2-138
                } else {
                    sa[i + 1] = sa[i] + Pc - rr; //2-140
                }
                if (sa[i + 1] > s0) {
                    sa[i + 1] = s0; //表层蓄水量不能超过超过表层蓄水容量，即饱和状态
                }
                //下层土壤蓄水量ua[i+1]
                ua[i + 1] = ua[i] + rr - y[i]; //2-141
                if (ua[i + 1] > u0) {
                    ua[i + 1] = u0;
                }
                //                }
                Eb = 0.0;
            } else {//---------当日流域平均降雨量小于流域平均蒸散发能力，即P<Ed时--------//
                rr = 0.0; //下渗强度
                Ec = EDt - floodDrp[i]; //2-144
                Eb = Eb + Ec; //2-145
                //                if (Eb > sa[0]) {
                //                    Eb = sa[0]; //限制蒸发深度
                //                }

                //表层可蒸发量Eu,两个假定
                double temp1 = (Math.pow(1 - (Eb - Ec) / (a * s0), a));
                double temp2 = (Math.pow(1 - Eb / (a * s0), a));
                //Eu = s0 * (temp1 - temp2); //2-146
                ////////防止出现负数///////////////
                if (Eb / (a * s0) <= 0.999999 & (Eb - Ec) / (a * s0) <= 0.999999) {
                    Eu = s0 * (temp1 - temp2); // 2-146
                } else if (Eb / (a * s0) >= 1.00001 & (Eb - Ec) / (a * s0) <= 0.999999) {
                    Eu = s0 * Math.pow(temp1, a);
                } else {
                    Eu = 0.00001;
                }

                if (sa[i] - Eu < 0.0) {
                    EL = (Ec - sa[i]) * ua[i] / u0; //2-149
                    if (i + 1 < floodRainRange) {
                        sa[i + 1] = 0.0;
                        ua[i + 1] = ua[i] - EL; //2-150
                        if (ua[i + 1] < 0.0) {
                            ua[i + 1] = 0.0;
                        }
                    }
                } else {
                    EL = (Ec - Eu) * ua[i] / u0; //2-148
                    if (i + 1 < floodRainRange) {
                        sa[i + 1] = sa[i] - Eu; //2-147
                        ua[i + 1] = ua[i] - EL; //2-150
                        if (ua[i + 1] < 0.0) {
                            ua[i + 1] = 0.0;
                        }
                    }
                }

                y[i] = 0.0; //表层径流和地下径流之和
                y0[i] = 0.0; //直接径流
                yu[i] = 0.0; //地面壤中流
                yL[i] = 0.0; //地下径流
            }

            /*需保留最后一个时段末的状态值，去掉时段初值限制条件*/
            //            if(i + 1 < floodRainRange) {
            if (sa[i + 1] > s0) {
                sa[i + 1] = s0; // 表层蓄水量不能超过表层蓄水容量，即饱和状态
            }
            if (sa[i + 1] < 0) {
                sa[i + 1] = 0;
            }
            if (ua[i + 1] < 0) {
                ua[i + 1] = 0f;
            }
            if (ua[i + 1] > u0) {
                ua[i + 1] = u0;
                // System.out.println("**ua["+(i+1)+"]"+ua[i+1]);
            }
            //            }
        }
    }

    //   private double f_emt( Date dt_rain, double pt) {
    //        //得到该时刻的时段蒸发能力，time_step—表示时段间隔,emt—表示各月蒸发能力，
    //        //pt—表示时段降雨，dt_rain—表示降雨时间
    //        int iNumLevel = rainLevel.length; //表示是晴天、雨天或阴天的情况数
    //        int level = 0;
    //        double p_day = pt * 24 / timeInterval; //将时段降雨转换成日降雨
    //        for (int i = 0; i < iNumLevel; i++) {
    //            if (p_day <= rainLevel[i]) {
    //                level = i;
    //                break;
    //            }
    //        }
    //        Calendar time = Calendar.getInstance();
    //        time.setTime(dt_rain); //降雨现在时间
    //        int i_month = time.get(Calendar.MONTH) + 1; //得到月数
    //        double ev = Eall[level][i_month];;
    //        ev = ev * timeInterval / 24; //时段蒸发能力
    //        return ev;
    //    }
    public void dhf_flow() {
        int TT = 0; //地下径流汇流曲线宽度
        int TS = 0; //地表峰现时间
        int TL = 0; //总汇流曲线宽度
        double w0 = Area /
                (3.6 * timeInterval); //R 单位转换系数（km2/h = 1000000 m2/ 3600 s = 1000m2/3.6s，km2·mm/h = 1000000 * 0.001 m3/
        // 3600 s = m3/3.6s）
        for (int i = 0; i < floodRainRange; i++) {
            // rL[i] = r[i] * c3; //c3 = 0.15f,c3修正参数，曲线拟合更好
            // Tm是时段降雨与前期影响净雨（已产生的径流）的函数
            if (ya[i] < 0.5) {
                ya[i] = 0.5; // 防止计算
            }
            double tempTm = (Math.pow(ya[i] + RunoffSim[i], -K0));
            LB = L / B0;
            Tm = LB * tempTm; // 2-152
            //ya0 = K * (ya0 + RunoffSim[i]); // 2-153

            TT = (int) (N * Tm);
            TS = (int) (COE * Tm);

            double tempAAL = (Math.pow(PAI * COE / N, DDL - 1));
            AAL = (CCL / (DDL * tempAAL * Math.tan(PAI * COE / N)));//2-154
            K3L = 0.0;
            for (int j = 0; j < TT; j++) {
                double tmp = Math.pow(PAI * j / TT, DDL);
                double tmp1 = Math.pow(Math.sin(PAI * j / TT), CCL);
                K3L = K3L + Math.exp(-AAL * tmp) * tmp1;
            }
            K3L = TT * w0 / K3L;//2-155

            K3 = 0.0; // 初始化K3
            double tempAA = Math.pow(PAI * COE, DD - 1);
            AA = CC / (DD * tempAA * Math.tan(PAI * COE)); // 2-154,峰的位置参数
            for (int j = 0; j < Tm; j++) {
                double tmp = Math.pow(PAI * j / Tm, DD);
                double tmp1 = Math.pow(Math.sin(PAI * j / Tm), CC);
                K3 = K3 + Math.exp(-AA * tmp) * tmp1; // 2-155
            }
            K3 = Tm * w0 / K3; // 相等于参考书上面的K3

            TL = TT + TS - 1;
            if (TL <= 0) {
                TL = 0;
            }
            // System.out.println("AA:" + AA + ",AAL:" + AAL + ",K3:" + K3);
            for (int j = 0; j < TL; j++) { // 2-151
                if (i + j == QSim.length) {// 怕越界/////////////////彭勇//////////////////
                    TL = j;
                    break;
                }
                double temp0 = PAI * j / Tm;
                double temp1 = (Math.pow(temp0, DD));
                double temp2 = (Math.exp(-AA * temp1));
                double temp3 = (Math.pow(Math.sin(temp0), CC));
                double Qs = (RunoffSim[i] - rL[i]) * K3 / Tm * temp2 * temp3; // Kb=K3
                if (Double.isNaN(Qs))
                    Qs = 0;

                double temp00 = PAI * (j - TS) / TT;
                double temp10 = (Math.pow(temp00, DDL));
                double temp20 = (Math.exp(-AAL * temp10));
                double temp30 = (Math.pow(Math.sin(temp00), CCL));
                double Ql = rL[i] * K3L / TT * temp20 * temp30;
                if (j <= Tm) {
                    if (j <= TS) {
                        ql[i + j] += 0.0;
                        qs[i + j] += Qs;
                    }
                    //                    else if (j <= Tm / 2) {
                    //                        QSim[i + j] += Qs + Ql;
                    //                    }
                    else {
                        //                        Qs = (RunoffSim[i] - rL[i]) * K3 / Tm * temp2;
                        qs[i + j] += Qs;
                        ql[i + j] += Ql;
                    }
                } else {
                    qs[i + j] += 0.0;
                    //                    if (j <= TS + TT / 2) {
                    ql[i + j] += Ql;
                    //                    } else {
                    //                        Ql = rL[i] * K3L / TT * temp20;
                    //                        QSim[i + j] += Ql;
                    //                    }
                }
                QSim[i + j] = qs[i + j] + ql[i + j];
                if (QSim[i + j] < 0.0f) {
                    QSim[i + j] = 0.0f;
                }
            }
        }
    }

    /**
     * 蒸发计算
     *
     * @param date   降水时间
     * @param timeIn 时间间隔 (h)
     * @return 蒸发
     */
    private double calcEvaporationPotential(Date date, double timeIn) {
        Calendar time = Calendar.getInstance();
        time.setTime(date);
        Integer Month = time.get(Calendar.MONTH) + 1; // 获得降雨开始月份

        /*
        double[] Ev = new double[3]; // 根据月份确定该时刻小雨、中雨、大雨的蒸发能力;

        if (Month == 4)
            Ev = Eall[0];
        else if (Month == 5)
            Ev = Eall[1];
        else if (Month == 6)
            Ev = Eall[2];
        else if (Month == 7)
            Ev = Eall[3];
        else if (Month == 8)
            Ev = Eall[4];
        else if (Month == 9)
            Ev = Eall[5];
        else if (Month == 10)
            Ev = Eall[6];
        else
            System.out.println("The Evaporation of some MONTHs is not found.");

        rain = rain * 24 / timeIn;  //时段降雨量转换成日降雨量

        double[] Ms = calcRainMembership(rain); // 计算该场降雨对小雨、中雨、大雨的隶属度

        */

        double Ep = ES[Month - 1] / 30; // 月蒸发量转换成日蒸发量

        /*
        for (int i = 0; i < Ms.length; i++) { // 隶属度和蒸发数组加权求和
            Ep += Ev[i] * Ms[i];
        }
        */

        Ep = Ep * timeIn / 24; // 日蒸发量转换成时段蒸发量
        return Ep;
    }

    /**
     * 模型计算
     */
    public Map<String, double[]> DHF_Model() {
        //dhf_runoff(preFloodRainRange,preTimeInterval,preFloodTm,preFloodDrp);
        //大伙房产流
        dhf_runoff();

        for (Integer j = 0; j < floodRainRange; j++) {
            RunoffSim[j] = y[j] + y0[j]; //总径流,2-137
            if (RunoffSim[j] < 0.0) {
                RunoffSim[j] = 0.0;
            }
            rL[j] = yL[j]; //地下水库下渗强度
            if (rL[j] < 0.0) {
                rL[j] = 0.0;
            }

            /*需保留最后一个时段末的状态值，去掉时段初值限制条件*/
            //            if(j + 1 < floodRainRange) {
            ya[j + 1] = (ya[j] + RunoffSim[j]) * Ka;// 2-153
            if (ya[j + 1] < 0.0) {
                ya[j + 1] = 0.0;
            }

            //            }
        }

        //大伙房汇流
        dhf_flow();

        Map<String, double[]> simulationResult = new HashMap<>();

        simulationResult.put("rain", floodDrp);
        simulationResult.put("PE", PE);
        simulationResult.put("runoffSim", RunoffSim);
        simulationResult.put("y0", y0);
        simulationResult.put("yu", yu);
        simulationResult.put("yL", yL);
        simulationResult.put("y", y);
        simulationResult.put("qs", qs);
        simulationResult.put("ql", ql);
        simulationResult.put("QSim", QSim);

        return simulationResult;
    }

    private List<String> toStringList(double[] array0) {
        String[] array = new String[array0.length];
        for (int i = 0; i < array.length; i++) {
            array[i] = String.valueOf(array0[i]);
        }
        return Arrays.asList(array);
    }
    public static void main(String[] args) {
        String a = "{\"DD\":\"0.681\",\"A\":\"4.979\",\"B\":\"1.05\",\"K0\":\"0.466\",\"F\":\"2379.852\",\"K2\":\"0.389\",\"G\":\"0.741\",\"K\":\"0.897\",\"L\":\"99.674\",\"DDL\":\"0.612\",\"N\":\"4.069\",\"dt\":\"[\\\"2024-06-04 08:00:00\\\",\\\"2024-06-04 11:00:00\\\",\\\"2024-06-04 14:00:00\\\",\\\"2024-06-04 17:00:00\\\",\\\"2024-06-04 20:00:00\\\",\\\"2024-06-04 23:00:00\\\",\\\"2024-06-05 02:00:00\\\",\\\"2024-06-05 05:00:00\\\",\\\"2024-06-05 08:00:00\\\",\\\"2024-06-05 11:00:00\\\",\\\"2024-06-05 14:00:00\\\",\\\"2024-06-05 17:00:00\\\",\\\"2024-06-05 20:00:00\\\",\\\"2024-06-05 23:00:00\\\",\\\"2024-06-06 02:00:00\\\",\\\"2024-06-06 05:00:00\\\",\\\"2024-06-06 08:00:00\\\",\\\"2024-06-06 11:00:00\\\",\\\"2024-06-06 14:00:00\\\",\\\"2024-06-06 17:00:00\\\",\\\"2024-06-06 20:00:00\\\",\\\"2024-06-06 23:00:00\\\",\\\"2024-06-07 02:00:00\\\",\\\"2024-06-07 05:00:00\\\",\\\"2024-06-07 08:00:00\\\",\\\"2024-06-07 11:00:00\\\",\\\"2024-06-07 14:00:00\\\",\\\"2024-06-07 17:00:00\\\",\\\"2024-06-07 20:00:00\\\",\\\"2024-06-07 23:00:00\\\",\\\"2024-06-08 02:00:00\\\",\\\"2024-06-08 05:00:00\\\",\\\"2024-06-08 08:00:00\\\",\\\"2024-06-08 11:00:00\\\",\\\"2024-06-08 14:00:00\\\",\\\"2024-06-08 17:00:00\\\",\\\"2024-06-08 20:00:00\\\",\\\"2024-06-08 23:00:00\\\",\\\"2024-06-09 02:00:00\\\",\\\"2024-06-09 05:00:00\\\",\\\"2024-06-09 08:00:00\\\",\\\"2024-06-09 11:00:00\\\",\\\"2024-06-09 14:00:00\\\",\\\"2024-06-09 17:00:00\\\",\\\"2024-06-09 20:00:00\\\",\\\"2024-06-09 23:00:00\\\",\\\"2024-06-10 02:00:00\\\",\\\"2024-06-10 05:00:00\\\",\\\"2024-06-10 08:00:00\\\",\\\"2024-06-10 11:00:00\\\",\\\"2024-06-10 14:00:00\\\",\\\"2024-06-10 17:00:00\\\",\\\"2024-06-10 20:00:00\\\",\\\"2024-06-10 23:00:00\\\",\\\"2024-06-11 02:00:00\\\",\\\"2024-06-11 05:00:00\\\",\\\"2024-06-11 08:00:00\\\",\\\"2024-06-11 11:00:00\\\",\\\"2024-06-11 14:00:00\\\",\\\"2024-06-11 17:00:00\\\",\\\"2024-06-11 20:00:00\\\",\\\"2024-06-11 23:00:00\\\",\\\"2024-06-12 02:00:00\\\",\\\"2024-06-12 05:00:00\\\",\\\"2024-06-12 08:00:00\\\",\\\"2024-06-12 11:00:00\\\",\\\"2024-06-12 14:00:00\\\",\\\"2024-06-12 17:00:00\\\",\\\"2024-06-12 20:00:00\\\",\\\"2024-06-12 23:00:00\\\",\\\"2024-06-13 02:00:00\\\",\\\"2024-06-13 05:00:00\\\",\\\"2024-06-13 08:00:00\\\",\\\"2024-06-13 11:00:00\\\",\\\"2024-06-13 14:00:00\\\",\\\"2024-06-13 17:00:00\\\",\\\"2024-06-13 20:00:00\\\",\\\"2024-06-13 23:00:00\\\",\\\"2024-06-14 02:00:00\\\",\\\"2024-06-14 05:00:00\\\",\\\"2024-06-14 08:00:00\\\",\\\"2024-06-14 11:00:00\\\",\\\"2024-06-14 14:00:00\\\",\\\"2024-06-14 17:00:00\\\",\\\"2024-06-14 20:00:00\\\",\\\"2024-06-14 23:00:00\\\",\\\"2024-06-15 02:00:00\\\",\\\"2024-06-15 05:00:00\\\",\\\"2024-06-15 08:00:00\\\",\\\"2024-06-15 11:00:00\\\",\\\"2024-06-15 14:00:00\\\",\\\"2024-06-15 17:00:00\\\",\\\"2024-06-15 20:00:00\\\",\\\"2024-06-15 23:00:00\\\",\\\"2024-06-16 02:00:00\\\",\\\"2024-06-16 05:00:00\\\",\\\"2024-06-16 08:00:00\\\",\\\"2024-06-16 11:00:00\\\",\\\"2024-06-16 14:00:00\\\",\\\"2024-06-16 17:00:00\\\",\\\"2024-06-16 20:00:00\\\",\\\"2024-06-16 23:00:00\\\",\\\"2024-06-17 02:00:00\\\",\\\"2024-06-17 05:00:00\\\",\\\"2024-06-17 08:00:00\\\",\\\"2024-06-17 11:00:00\\\",\\\"2024-06-17 14:00:00\\\",\\\"2024-06-17 17:00:00\\\",\\\"2024-06-17 20:00:00\\\",\\\"2024-06-17 23:00:00\\\",\\\"2024-06-18 02:00:00\\\",\\\"2024-06-18 05:00:00\\\",\\\"2024-06-18 08:00:00\\\",\\\"2024-06-18 11:00:00\\\",\\\"2024-06-18 14:00:00\\\",\\\"2024-06-18 17:00:00\\\",\\\"2024-06-18 20:00:00\\\",\\\"2024-06-18 23:00:00\\\",\\\"2024-06-19 02:00:00\\\",\\\"2024-06-19 05:00:00\\\",\\\"2024-06-19 08:00:00\\\",\\\"2024-06-19 11:00:00\\\",\\\"2024-06-19 14:00:00\\\",\\\"2024-06-19 17:00:00\\\",\\\"2024-06-19 20:00:00\\\",\\\"2024-06-19 23:00:00\\\",\\\"2024-06-20 02:00:00\\\",\\\"2024-06-20 05:00:00\\\",\\\"2024-06-20 08:00:00\\\",\\\"2024-06-20 11:00:00\\\",\\\"2024-06-20 14:00:00\\\",\\\"2024-06-20 17:00:00\\\",\\\"2024-06-20 20:00:00\\\",\\\"2024-06-20 23:00:00\\\",\\\"2024-06-21 02:00:00\\\",\\\"2024-06-21 05:00:00\\\",\\\"2024-06-21 08:00:00\\\",\\\"2024-06-21 11:00:00\\\",\\\"2024-06-21 14:00:00\\\",\\\"2024-06-21 17:00:00\\\",\\\"2024-06-21 20:00:00\\\",\\\"2024-06-21 23:00:00\\\",\\\"2024-06-22 02:00:00\\\",\\\"2024-06-22 05:00:00\\\",\\\"2024-06-22 08:00:00\\\",\\\"2024-06-22 11:00:00\\\",\\\"2024-06-22 14:00:00\\\",\\\"2024-06-22 17:00:00\\\",\\\"2024-06-22 20:00:00\\\",\\\"2024-06-22 23:00:00\\\",\\\"2024-06-23 02:00:00\\\",\\\"2024-06-23 05:00:00\\\",\\\"2024-06-23 08:00:00\\\",\\\"2024-06-23 11:00:00\\\",\\\"2024-06-23 14:00:00\\\",\\\"2024-06-23 17:00:00\\\",\\\"2024-06-23 20:00:00\\\",\\\"2024-06-23 23:00:00\\\",\\\"2024-06-24 02:00:00\\\",\\\"2024-06-24 05:00:00\\\",\\\"2024-06-24 08:00:00\\\",\\\"2024-06-24 11:00:00\\\",\\\"2024-06-24 14:00:00\\\",\\\"2024-06-24 17:00:00\\\",\\\"2024-06-24 20:00:00\\\",\\\"2024-06-24 23:00:00\\\",\\\"2024-06-25 02:00:00\\\",\\\"2024-06-25 05:00:00\\\",\\\"2024-06-25 08:00:00\\\",\\\"2024-06-25 11:00:00\\\",\\\"2024-06-25 14:00:00\\\",\\\"2024-06-25 17:00:00\\\",\\\"2024-06-25 20:00:00\\\",\\\"2024-06-25 23:00:00\\\",\\\"2024-06-26 02:00:00\\\",\\\"2024-06-26 05:00:00\\\",\\\"2024-06-26 08:00:00\\\",\\\"2024-06-26 11:00:00\\\",\\\"2024-06-26 14:00:00\\\",\\\"2024-06-26 17:00:00\\\",\\\"2024-06-26 20:00:00\\\",\\\"2024-06-26 23:00:00\\\",\\\"2024-06-27 02:00:00\\\",\\\"2024-06-27 05:00:00\\\",\\\"2024-06-27 08:00:00\\\",\\\"2024-06-27 11:00:00\\\",\\\"2024-06-27 14:00:00\\\",\\\"2024-06-27 17:00:00\\\",\\\"2024-06-27 20:00:00\\\",\\\"2024-06-27 23:00:00\\\",\\\"2024-06-28 02:00:00\\\",\\\"2024-06-28 05:00:00\\\",\\\"2024-06-28 08:00:00\\\",\\\"2024-06-28 11:00:00\\\",\\\"2024-06-28 14:00:00\\\",\\\"2024-06-28 17:00:00\\\",\\\"2024-06-28 20:00:00\\\",\\\"2024-06-28 23:00:00\\\",\\\"2024-06-29 02:00:00\\\",\\\"2024-06-29 05:00:00\\\",\\\"2024-06-29 08:00:00\\\",\\\"2024-06-29 11:00:00\\\",\\\"2024-06-29 14:00:00\\\",\\\"2024-06-29 17:00:00\\\",\\\"2024-06-29 20:00:00\\\",\\\"2024-06-29 23:00:00\\\",\\\"2024-06-30 02:00:00\\\",\\\"2024-06-30 05:00:00\\\",\\\"2024-06-30 08:00:00\\\",\\\"2024-06-30 11:00:00\\\",\\\"2024-06-30 14:00:00\\\",\\\"2024-06-30 17:00:00\\\",\\\"2024-06-30 20:00:00\\\",\\\"2024-06-30 23:00:00\\\",\\\"2024-07-01 02:00:00\\\",\\\"2024-07-01 05:00:00\\\",\\\"2024-07-01 08:00:00\\\",\\\"2024-07-01 11:00:00\\\",\\\"2024-07-01 14:00:00\\\",\\\"2024-07-01 17:00:00\\\",\\\"2024-07-01 20:00:00\\\",\\\"2024-07-01 23:00:00\\\",\\\"2024-07-02 02:00:00\\\",\\\"2024-07-02 05:00:00\\\",\\\"2024-07-02 08:00:00\\\",\\\"2024-07-02 11:00:00\\\",\\\"2024-07-02 14:00:00\\\",\\\"2024-07-02 17:00:00\\\",\\\"2024-07-02 20:00:00\\\",\\\"2024-07-02 23:00:00\\\",\\\"2024-07-03 02:00:00\\\",\\\"2024-07-03 05:00:00\\\",\\\"2024-07-03 08:00:00\\\",\\\"2024-07-03 11:00:00\\\",\\\"2024-07-03 14:00:00\\\",\\\"2024-07-03 17:00:00\\\",\\\"2024-07-03 20:00:00\\\",\\\"2024-07-03 23:00:00\\\",\\\"2024-07-04 02:00:00\\\",\\\"2024-07-04 05:00:00\\\",\\\"2024-07-04 08:00:00\\\",\\\"2024-07-04 11:00:00\\\",\\\"2024-07-04 14:00:00\\\",\\\"2024-07-04 17:00:00\\\",\\\"2024-07-04 20:00:00\\\",\\\"2024-07-04 23:00:00\\\",\\\"2024-07-05 02:00:00\\\",\\\"2024-07-05 05:00:00\\\",\\\"2024-07-05 08:00:00\\\",\\\"2024-07-05 11:00:00\\\",\\\"2024-07-05 14:00:00\\\",\\\"2024-07-05 17:00:00\\\",\\\"2024-07-05 20:00:00\\\",\\\"2024-07-05 23:00:00\\\",\\\"2024-07-06 02:00:00\\\",\\\"2024-07-06 05:00:00\\\",\\\"2024-07-06 08:00:00\\\",\\\"2024-07-06 11:00:00\\\",\\\"2024-07-06 14:00:00\\\",\\\"2024-07-06 17:00:00\\\",\\\"2024-07-06 20:00:00\\\",\\\"2024-07-06 23:00:00\\\",\\\"2024-07-07 02:00:00\\\",\\\"2024-07-07 05:00:00\\\",\\\"2024-07-07 08:00:00\\\",\\\"2024-07-07 11:00:00\\\",\\\"2024-07-07 14:00:00\\\",\\\"2024-07-07 17:00:00\\\",\\\"2024-07-07 20:00:00\\\",\\\"2024-07-07 23:00:00\\\",\\\"2024-07-08 02:00:00\\\",\\\"2024-07-08 05:00:00\\\",\\\"2024-07-08 08:00:00\\\",\\\"2024-07-08 11:00:00\\\",\\\"2024-07-08 14:00:00\\\",\\\"2024-07-08 17:00:00\\\",\\\"2024-07-08 20:00:00\\\",\\\"2024-07-08 23:00:00\\\",\\\"2024-07-09 02:00:00\\\",\\\"2024-07-09 05:00:00\\\",\\\"2024-07-09 08:00:00\\\",\\\"2024-07-09 11:00:00\\\",\\\"2024-07-09 14:00:00\\\",\\\"2024-07-09 17:00:00\\\",\\\"2024-07-09 20:00:00\\\",\\\"2024-07-09 23:00:00\\\",\\\"2024-07-10 02:00:00\\\",\\\"2024-07-10 05:00:00\\\",\\\"2024-07-10 08:00:00\\\",\\\"2024-07-10 11:00:00\\\",\\\"2024-07-10 14:00:00\\\",\\\"2024-07-10 17:00:00\\\",\\\"2024-07-10 20:00:00\\\",\\\"2024-07-10 23:00:00\\\",\\\"2024-07-11 02:00:00\\\",\\\"2024-07-11 05:00:00\\\",\\\"2024-07-11 08:00:00\\\",\\\"2024-07-11 11:00:00\\\",\\\"2024-07-11 14:00:00\\\",\\\"2024-07-11 17:00:00\\\",\\\"2024-07-11 20:00:00\\\",\\\"2024-07-11 23:00:00\\\",\\\"2024-07-12 02:00:00\\\",\\\"2024-07-12 05:00:00\\\",\\\"2024-07-12 08:00:00\\\",\\\"2024-07-12 11:00:00\\\",\\\"2024-07-12 14:00:00\\\",\\\"2024-07-12 17:00:00\\\",\\\"2024-07-12 20:00:00\\\",\\\"2024-07-12 23:00:00\\\",\\\"2024-07-13 02:00:00\\\",\\\"2024-07-13 05:00:00\\\",\\\"2024-07-13 08:00:00\\\",\\\"2024-07-13 11:00:00\\\",\\\"2024-07-13 14:00:00\\\",\\\"2024-07-13 17:00:00\\\",\\\"2024-07-13 20:00:00\\\",\\\"2024-07-13 23:00:00\\\",\\\"2024-07-14 02:00:00\\\",\\\"2024-07-14 05:00:00\\\",\\\"2024-07-14 08:00:00\\\",\\\"2024-07-14 11:00:00\\\",\\\"2024-07-14 14:00:00\\\",\\\"2024-07-14 17:00:00\\\",\\\"2024-07-14 20:00:00\\\",\\\"2024-07-14 23:00:00\\\",\\\"2024-07-15 02:00:00\\\",\\\"2024-07-15 05:00:00\\\",\\\"2024-07-15 08:00:00\\\",\\\"2024-07-15 11:00:00\\\",\\\"2024-07-15 14:00:00\\\",\\\"2024-07-15 17:00:00\\\",\\\"2024-07-15 20:00:00\\\",\\\"2024-07-15 23:00:00\\\",\\\"2024-07-16 02:00:00\\\",\\\"2024-07-16 05:00:00\\\",\\\"2024-07-16 08:00:00\\\",\\\"2024-07-16 11:00:00\\\",\\\"2024-07-16 14:00:00\\\",\\\"2024-07-16 17:00:00\\\",\\\"2024-07-16 20:00:00\\\",\\\"2024-07-16 23:00:00\\\",\\\"2024-07-17 02:00:00\\\",\\\"2024-07-17 05:00:00\\\",\\\"2024-07-17 08:00:00\\\",\\\"2024-07-17 11:00:00\\\",\\\"2024-07-17 14:00:00\\\",\\\"2024-07-17 17:00:00\\\",\\\"2024-07-17 20:00:00\\\",\\\"2024-07-17 23:00:00\\\",\\\"2024-07-18 02:00:00\\\",\\\"2024-07-18 05:00:00\\\",\\\"2024-07-18 08:00:00\\\",\\\"2024-07-18 11:00:00\\\",\\\"2024-07-18 14:00:00\\\",\\\"2024-07-18 17:00:00\\\",\\\"2024-07-18 20:00:00\\\",\\\"2024-07-18 23:00:00\\\",\\\"2024-07-19 02:00:00\\\",\\\"2024-07-19 05:00:00\\\",\\\"2024-07-19 08:00:00\\\",\\\"2024-07-19 11:00:00\\\",\\\"2024-07-19 14:00:00\\\",\\\"2024-07-19 17:00:00\\\",\\\"2024-07-19 20:00:00\\\",\\\"2024-07-19 23:00:00\\\",\\\"2024-07-20 02:00:00\\\",\\\"2024-07-20 05:00:00\\\",\\\"2024-07-20 08:00:00\\\",\\\"2024-07-20 11:00:00\\\",\\\"2024-07-20 14:00:00\\\",\\\"2024-07-20 17:00:00\\\",\\\"2024-07-20 20:00:00\\\",\\\"2024-07-20 23:00:00\\\",\\\"2024-07-21 02:00:00\\\",\\\"2024-07-21 05:00:00\\\",\\\"2024-07-21 08:00:00\\\",\\\"2024-07-21 11:00:00\\\",\\\"2024-07-21 14:00:00\\\",\\\"2024-07-21 17:00:00\\\",\\\"2024-07-21 20:00:00\\\",\\\"2024-07-21 23:00:00\\\",\\\"2024-07-22 02:00:00\\\",\\\"2024-07-22 05:00:00\\\",\\\"2024-07-22 08:00:00\\\",\\\"2024-07-22 11:00:00\\\",\\\"2024-07-22 14:00:00\\\",\\\"2024-07-22 17:00:00\\\",\\\"2024-07-22 20:00:00\\\",\\\"2024-07-22 23:00:00\\\",\\\"2024-07-23 02:00:00\\\",\\\"2024-07-23 05:00:00\\\",\\\"2024-07-23 08:00:00\\\",\\\"2024-07-23 11:00:00\\\",\\\"2024-07-23 14:00:00\\\",\\\"2024-07-23 17:00:00\\\",\\\"2024-07-23 20:00:00\\\",\\\"2024-07-23 23:00:00\\\",\\\"2024-07-24 02:00:00\\\",\\\"2024-07-24 05:00:00\\\",\\\"2024-07-24 08:00:00\\\",\\\"2024-07-24 11:00:00\\\",\\\"2024-07-24 14:00:00\\\",\\\"2024-07-24 17:00:00\\\",\\\"2024-07-24 20:00:00\\\",\\\"2024-07-24 23:00:00\\\",\\\"2024-07-25 02:00:00\\\",\\\"2024-07-25 05:00:00\\\",\\\"2024-07-25 08:00:00\\\",\\\"2024-07-25 11:00:00\\\",\\\"2024-07-25 14:00:00\\\",\\\"2024-07-25 17:00:00\\\",\\\"2024-07-25 20:00:00\\\",\\\"2024-07-25 23:00:00\\\",\\\"2024-07-26 02:00:00\\\",\\\"2024-07-26 05:00:00\\\",\\\"2024-07-26 08:00:00\\\",\\\"2024-07-26 11:00:00\\\",\\\"2024-07-26 14:00:00\\\",\\\"2024-07-26 17:00:00\\\",\\\"2024-07-26 20:00:00\\\",\\\"2024-07-26 23:00:00\\\",\\\"2024-07-27 02:00:00\\\",\\\"2024-07-27 05:00:00\\\",\\\"2024-07-27 08:00:00\\\",\\\"2024-07-27 11:00:00\\\",\\\"2024-07-27 14:00:00\\\",\\\"2024-07-27 17:00:00\\\",\\\"2024-07-27 20:00:00\\\",\\\"2024-07-27 23:00:00\\\",\\\"2024-07-28 02:00:00\\\",\\\"2024-07-28 05:00:00\\\",\\\"2024-07-28 08:00:00\\\",\\\"2024-07-28 11:00:00\\\",\\\"2024-07-28 14:00:00\\\",\\\"2024-07-28 17:00:00\\\",\\\"2024-07-28 20:00:00\\\",\\\"2024-07-28 23:00:00\\\",\\\"2024-07-29 02:00:00\\\",\\\"2024-07-29 05:00:00\\\",\\\"2024-07-29 08:00:00\\\",\\\"2024-07-29 11:00:00\\\",\\\"2024-07-29 14:00:00\\\",\\\"2024-07-29 17:00:00\\\",\\\"2024-07-29 20:00:00\\\",\\\"2024-07-29 23:00:00\\\",\\\"2024-07-30 02:00:00\\\",\\\"2024-07-30 05:00:00\\\",\\\"2024-07-30 08:00:00\\\",\\\"2024-07-30 11:00:00\\\",\\\"2024-07-30 14:00:00\\\",\\\"2024-07-30 17:00:00\\\",\\\"2024-07-30 20:00:00\\\",\\\"2024-07-30 23:00:00\\\",\\\"2024-07-31 02:00:00\\\",\\\"2024-07-31 05:00:00\\\",\\\"2024-07-31 08:00:00\\\",\\\"2024-07-31 11:00:00\\\",\\\"2024-07-31 14:00:00\\\",\\\"2024-07-31 17:00:00\\\",\\\"2024-07-31 20:00:00\\\",\\\"2024-07-31 23:00:00\\\",\\\"2024-08-01 02:00:00\\\",\\\"2024-08-01 05:00:00\\\",\\\"2024-08-01 08:00:00\\\",\\\"2024-08-01 11:00:00\\\",\\\"2024-08-01 14:00:00\\\",\\\"2024-08-01 17:00:00\\\",\\\"2024-08-01 20:00:00\\\",\\\"2024-08-01 23:00:00\\\",\\\"2024-08-02 02:00:00\\\",\\\"2024-08-02 05:00:00\\\",\\\"2024-08-02 08:00:00\\\",\\\"2024-08-02 11:00:00\\\",\\\"2024-08-02 14:00:00\\\",\\\"2024-08-02 17:00:00\\\",\\\"2024-08-02 20:00:00\\\",\\\"2024-08-02 23:00:00\\\",\\\"2024-08-03 02:00:00\\\",\\\"2024-08-03 05:00:00\\\",\\\"2024-08-03 08:00:00\\\",\\\"2024-08-03 11:00:00\\\",\\\"2024-08-03 14:00:00\\\",\\\"2024-08-03 17:00:00\\\",\\\"2024-08-03 20:00:00\\\",\\\"2024-08-03 23:00:00\\\",\\\"2024-08-04 02:00:00\\\",\\\"2024-08-04 05:00:00\\\",\\\"2024-08-04 08:00:00\\\",\\\"2024-08-04 11:00:00\\\",\\\"2024-08-04 14:00:00\\\",\\\"2024-08-04 17:00:00\\\",\\\"2024-08-04 20:00:00\\\",\\\"2024-08-04 23:00:00\\\",\\\"2024-08-05 02:00:00\\\",\\\"2024-08-05 05:00:00\\\",\\\"2024-08-05 08:00:00\\\",\\\"2024-08-05 11:00:00\\\",\\\"2024-08-05 14:00:00\\\",\\\"2024-08-05 17:00:00\\\",\\\"2024-08-05 20:00:00\\\",\\\"2024-08-05 23:00:00\\\",\\\"2024-08-06 02:00:00\\\",\\\"2024-08-06 05:00:00\\\",\\\"2024-08-06 08:00:00\\\",\\\"2024-08-06 11:00:00\\\",\\\"2024-08-06 14:00:00\\\",\\\"2024-08-06 17:00:00\\\",\\\"2024-08-06 20:00:00\\\"]\",\"KA\":\"0.72\",\"COE\":\"0.077\",\"CC\":\"0.623\",\"rain\":\"[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0023510972413793105,0.003526646,0.005195166517241379,0.011313075310344827,0.016874810482758622,0.011249873448275861,0.022372371862068967,0.033593076,0.055975366,0.07801374186206897,0.08708632255172413,0.09153571082758621,0.17558743496551724,0.11705828965517241,0.09697730737931035,0.22755610965517242,0.38542564948275865,0.16300719517241377,0.22459283068965516,0.26785108172413796,0.9646666158620689,0.24578528275862072,0.034482758620689655,0.017241379310344827,3.886206896551724,0.5344827586206897,0.0,1.9862068620689657,2.186206896551724,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.020689655172413793,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.9655172413793103,0.0,0.7068965517241379,0.5862068965517242,0.12068965517241378,2.593103448275862,0.017241379310344827,2.189655172413793,0.4827586206896552,0.041379310344827586,0.0,0.0,0.0,0.0,0.0,0.0,0.0034482758620689655,0.0,0.0,0.0,0.0,0.0,0.8275862068965516,0.4275862068965517,7.796551793103449,2.675862068965517,0.16551724137931034,0.7931034482758621,2.593103448275862,2.6068965517241383,0.017241379310344827,0.0,0.0,0.034482758620689655,0.0,0.0,0.0,0.5344827586206896,0.017241379310344827,0.0034482758620689655,0.0,0.017241379310344827,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0208947586206897E-17,1.0208947586206897E-17,1.0208947586206897E-17,1.0208947586206897E-17,0.03448275862068966,7.3310345172413784,5.36551724137931,0.05172413793103449,0.1724137931034483,0.0,1.2931034482758619,5.496551724137931,20.665517206896553,9.448275879310348,0.1758620689655173,0.0,0.0,0.017241379310344827,0.06896551724137931,0.0,0.0,0.26206896551724135,0.8517241379310345,0.7275862068965516,1.9896551724137925,4.4068965482758635,0.7758620689655172,0.10344827586206896,0.06551724137931034,0.13793103448275862,0.034482758620689655,0.19655172413793107,0.0,0.017241379310344827,0.0,0.0,0.0,0.0,0.017241379310344827,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.017241379310344827,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.017241379310344827,0.010344827586206896,0.0,0.034482758620689655,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.9482758620689655,7.317241389655172,13.920689793103447,0.034482758620689655,6.082758620689655,3.6758620551724146,0.30689655172413793,0.5862068965517242,0.017241379310344827,0.017241379310344827,0.0,0.0,0.0,0.0,0.0,0.017241379310344827,0.0,0.0,0.0,0.017241379310344827,0.0,2.187631724137931E-18,3.2814475862068966E-18,0.30689655172413793,3.2814475862068966E-18,0.5896551724137931,3.0999999999999996,1.7999999999999998,0.01724137931034483,1.3275862,7.341379310344828,5.451724148275862,9.806896551724137,8.631034448275862,6.1448275862068975,11.427586220689657,2.6689655172413795,0.2931034482758621,6.137931034482759,0.12068965517241381,0.0,0.6103448275862069,0.25517241379310346,2.6206896551724137,0.2413793103448276,0.0,3.258620689655172,1.9137931034482754,0.0,0.0,0.3448275862068966,0.017241379310344827,0.017241379310344827,0.017241379310344827,0.08620689655172414,0.017241379310344827,0.0,0.0,0.0,0.0,0.034482758620689655,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.017241379310344827,0.05172413793103448,0.034482758620689655,0.0,0.0,0.06896551724137931,0.041379310344827586,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.017241379310344827,0.0,0.0,0.0,0.0,0.0,0.0,0.034482758620689655,0.49310344827586206,0.7206896551724138,0.10689655172413795,0.3620689655172413,2.1068965413793106,4.120689658620689,3.0344827448275864,7.948275862068966,0.0,0.0,0.0,0.05172413793103448,0.0,0.01724137931034483,0.3689655172413794,1.006896551724138,4.375263448275862E-18,4.375263448275862E-18,4.375263448275862E-18,4.855172413793104,2.9168420689655172E-18,0.0,0.0,0.0,0.0,0.0,0.4206896551724138,6.582758620689655,6.172413789655172,2.7620689655172406,0.0,0.0,0.0,0.0,0.0,0.05172413793103448,0.034482758620689655,0.0,0.0,0.0,0.017241379310344827,0.0,0.0,0.11379310344827587,0.0,0.0,0.0,6.33448275862069,2.351724137931034,2.548275862068966,5.562068965517241,0.0,0.0,0.017241379310344827,0.0,0.7586206896551725,3.4034482758620688,1.2000000000000002,6.427586203448276,0.017241379310344827,0.034482758620689655,0.0,0.0,0.0,0.0,0.3275862068965517,0.0,0.0,0.0,6.951724137931036,6.875862068965517,2.01724138275862,8.168965551724138,2.7172413793103445,9.103448310344827,7.858620689655172,10.720689689655174,9.444827620689654,21.18620693103448,13.234482758620691,15.320689655172414,3.5448275793103448,1.013793103448276,0.12068965517241387,3.7694575862068964E-17,0.0,0.3448275862068965,0.5068965517241378,3.9896551724137925,1.2241379310344824,3.5275862068965513,0.7000000000000001,11.313793103448276,5.468965517241379,2.4413793103448276,19.58965516206896,18.05172413965517,0.689655172413793,12.131034482758624,1.9275862068965512,0.13793103448275865,5.241379344827586,2.5689655172413794,0.6724137931034483,1.4413793103448276,0.0,0.0,1.0517241379310345,0.017241379310344827,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.12413793103448276,0.0,0.0,0.0,0.0,0.07241379310344828,2.4103448275862074,0.034482758620689655,0.10344827586206896,0.14827586206896554,2.6724137931034484,1.1379310344827585,3.9482758827586206,0.03103448275862069,0.1310344827586207,17.744827551724146,0.017241379310344827,0.0,0.05172413793103448,0.10344827586206896,0.0,0.0,0.0,0.017241379310344827,0.017241379310344827,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.08620689655172414,0.24482758620689657,0.8517241379310343,3.9344826896551726,0.06206896551724138,0.05172413793103448,0.25862068965517243,3.810344827586207,8.713793103448275,11.155172413793105,4.865517244827587,0.06896551724137932,1.5241379310344827,2.331034482758621,1.206896551724138,0.0,0.0,0.0]\",\"SA0\":\"0\",\"UA0\":\"0\",\"start\":\"\\\"2024-07-04 08:00:00\\\"\",\"YA0\":\"0.5\",\"D0\":\"77.331\",\"KW\":\"0.821\",\"CCL\":\"1.596\",\"ES\":\"[23.8, 23.2, 33.7, 53, 66.6, 78.9, 122.3, 113.9, 90.8, 62.9, 46.2, 34.1]\",\"B0\":\"0.563\",\"q\":\"[]\",\"runoffSim\":\"[]\",\"U0\":\"86.001\",\"clen\":\"3\",\"S0\":\"41.649\"}";
        Map data = JSON.parseObject(a, Map.class);
        DHF_ys obj = new DHF_ys(data);
        System.out.println(obj.predict());
    }
}
